import java.util.Scanner;

public class Jump {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        //在此输入您的代码...
        int n = scan.nextInt();
        int m = scan.nextInt();
        int[][] map = new int[n][m];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                map[i][j] =scan.nextInt();
            }
        }
        int[][] dp = new int[n][m];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                if (i == 0 && j == 0) {
                    dp[i][j] = map[0][0];
                    continue;
                }
                // 进行小范围的求较大值
                for (int k = i; k < n && k <= i + 3; k++) {
                    for (int l = j; l < m && l <= j + 3; l++) {
                        if (i + j > 3 || (k == i && l == j)) {
                            continue;
                        }
                        dp[k][l] = Math.max(dp[k][l], dp[i][j] + map[i][j]);
                    }
                }
            }
        }
        System.out.println(dp[n - 1][m - 1]);
        scan.close();
    }
}
